import axios from 'axios'
import * as constants from './constants'

export const changeLoginStatus = (loginStatus) => ({
  type:constants.CHANGE_LOGIN_STATUS,
  loginStatus
})

export const getLoginResult = (name, password) => {
  return (dispatch) => {
    axios.get('/api/login.json?name='+name+'&password='+password).then(
      (resp) => {
        dispatch(changeLoginStatus(true))
      }
    ).catch(
      (e) => {
        alert('数据加载失败请重试')
        console.log(e)
      }
    )
  }
}